<?xml version="1.0" encoding="UTF-8"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
	xmlns:f="http://xmlns.jcp.org/jsf/core"
	xmlns:h="http://xmlns.jcp.org/jsf/html"
	xmlns:p="http://primefaces.org/ui"
	xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
	template="/WEB-INF/templates/business/supplier/template.xhtml">

	<f:metadata>
		<f:event listener="#{loginedServiceSupplierController.init()}"
			type="preRenderView"></f:event>
		<f:viewParam
			name="serviceSupplierId"
			value="#{serviceSupplierHome.id}"
		></f:viewParam>
		<f:event listener="#{serviceSupplierHome.initConversation()}"
			type="preRenderView"></f:event>
		
	</f:metadata>

	<ui:define name="supplier_head">
		<style type="text/css">
			.removeButton {
				float: right;
				margin-right: 20px;
			}
			
			td {
				padding-bottom: 10px;
			}
			
			label {
				font-weight: bold;
			}
			
			.mylabel {
				width: 250px
			}
			
			.myvalue {
				width: 80%
			}
			input{width:400px;}
		</style>
		<h:outputStylesheet name="css/public/newuser-registration.css" />
		<h:outputStylesheet name="css/public/override_primefaces.css"></h:outputStylesheet>

	</ui:define>

	<ui:define name="supplier_content">

		<div class="sub_wrap">
			<div class="Methbox_tit">
				<h2>中介机构用户修改</h2>
				<span><p:link outcome="/index.xhtml" target="_blank">平台首页</p:link>
					&gt;</span>
			</div>
			<div class="Methbox_con">

				<h:form id="editForm">
					<p:messages id="messages" closable="true">
			       		<p:autoUpdate />
			       	</p:messages>
					<p:panel id="baseInfo" style="margin-bottom:10px;"
						styleClass="nureg-cont nuregcbox nuregcboxsty">

						<h:panelGrid columns="2" cellpadding="5"
							columnClasses="mylabel,myvalue">
							<p:outputLabel for="reason" value="驳回原因" style="color:red;" />
							<h:outputText id="reason" style="color:red;"
								value="#{serviceSupplierHome.instance.currRejectRecord.reason}" />
							<p:outputLabel for="cnname" value="公司名称" />
							<p:inputText id="cnname"
								value="#{serviceSupplierHome.instance.cnname}" required="true"
								styleClass="input-large" />

							<p:outputLabel for="companyType" value="单位性质或组织形式" />
							<p:selectOneMenu id="companyType"
								value="#{serviceSupplierHome.instance.companyType}"
								required="true">
								<f:selectItem itemLabel="请选择" itemValue="#{null}" />
								<f:selectItem itemLabel="国有企业" itemValue="国有企业" />
								<f:selectItem itemLabel="有限公司" itemValue="有限公司" />
								<f:selectItem itemLabel="事业单位" itemValue="事业单位" />
								<f:selectItem itemLabel="其他" itemValue="其他" />
							</p:selectOneMenu>

							<p:outputLabel for="creditCode" value="统一社会信用代码" />
							<p:inputText id="creditCode"
								value="#{serviceSupplierHome.instance.creditCode}"
								required="true" />
							<p:outputLabel for="registeredFund" value="注册资金(万元)" />
							<p:inputText id="registeredFund"
								value="#{serviceSupplierHome.instance.registeredFund}"
								required="true" styleClass="input-small" />

							<p:outputLabel for="registrationAuthority" value="注册登记机关" />
							<p:inputText id="registrationAuthority"
								value="#{serviceSupplierHome.instance.registrationAuthority}"
								required="true" styleClass="input-large" />

							<p:outputLabel for="registrationNo" value="注册登记号" />
							<p:inputText id="registrationNo"
								value="#{serviceSupplierHome.instance.registrationNo}" />

							<p:outputLabel for="regtime" value="成立时间" />
							<p:calendar id="regtime"
								value="#{serviceSupplierHome.instance.regtime}" required="true"
								pattern="yyyy-MM-dd" locale="zh_CN"
								inputStyleClass="input-small" showOn="button"
								readonlyInput="true" />

							<p:outputPanel>
								<p:outputLabel for="businessLicenseImageUpload" value="营业执照" />
								<br />
								（扫描图片上传）
							</p:outputPanel>
							<p:outputPanel>
								<p:fileUpload id="businessLicenseImageUpload" mode="advanced"
									skinSimple="true" required="true" fileLimit="1"
									fileLimitMessage="只能上传一个附件" allowTypes="/(\.|\/)(jpe?g|png)$/"
									sizeLimit="#{1024 * 1024 * 3}" uploadLabel="上传"
									cancelLabel="取消" update="editForm:businessLicenseImage"
									fileUploadListener="#{serviceSupplierHome.uploadBusinessLicenseImage}"></p:fileUpload>
								<p:panel id="businessLicenseImage" rendered="#{serviceSupplierHome.instance.businessLicenseImages.size() > 0}">
									<div id="imgsPreview" >
										<img  data-original="#{attachmentUtils.getFullPath(serviceSupplierHome.instance.businessLicenseImages[0])}" src="#{attachmentUtils.getFullPath(serviceSupplierHome.instance.businessLicenseImages[0])}"  id="img" width="240"/>
									</div>
									
								</p:panel>
							</p:outputPanel>
							
							<p:outputPanel>
								<p:outputLabel
									for="taxProveImagesUpload"
									value="纳税证明"
								/>
								<br />
								（扫描图片上传）
							</p:outputPanel>
							<p:outputPanel>												
								<p:fileUpload
									id="taxProveImagesUpload"
									label="选择"
									mode="advanced"
									multiple="true"
									skinSimple="true"
									sizeLimit="#{1024 * 1024 * 3}"
									uploadLabel="上传"
									cancelLabel="取消"
									update="editForm:taxProveImageList"
									fileUploadListener="#{serviceSupplierHome.uploadTaxProveImages}"
									allowTypes="/(\.|\/)(jpe?g|png)$/"
								/>
								<p:panel
									id="taxProveImageList"
									widgetVar="taxProveImageList">
									<p:dataList
										value="#{serviceSupplierHome.instance.taxProveImages}"
										var="_taxImage"
										rendered="#{serviceSupplierHome.instance.taxProveImages.size() > 0}"
										itemStyleClass="photoItem"
										varStatus="_certPhotoStatus"
									>
									<img  data-original="#{attachmentUtils.getFullPath(_taxImage)}" src="#{attachmentUtils.getFullPath(_taxImage)}"  id="img" width="240"/>
									<p:commandLink styleClass="closeBtn" action="#{serviceSupplierHome.removeTaxImage(_taxImage)}" update="editForm:taxProveImageList" immediate="true" ></p:commandLink>
									
									</p:dataList>
									<div style="clear: both" />
								</p:panel>
							</p:outputPanel>
							
							<p:outputLabel for="address" value="办公地址" />
							<p:inputText id="address"
								value="#{serviceSupplierHome.instance.address}" required="true"
								style="width:80%" />

							<p:outputLabel for="legalPerson" value="法定代表人" />
							<p:inputText id="legalPerson"
								value="#{serviceSupplierHome.instance.legalPerson}"
								required="true" styleClass="input-mini" />

							<p:outputLabel for="legalPersonPhoneNumber" value="法定代表人联系电话" />
							<p:inputText id="legalPersonPhoneNumber"
								value="#{serviceSupplierHome.instance.legalPersonPhoneNumber}"
								required="true" styleClass="input-small" />

							<p:outputLabel for="firstContactor" value="第一联系人" />
							<p:inputText id="firstContactor"
								value="#{serviceSupplierHome.instance.firstContactor}"
								required="true" styleClass="input-mini" />

							<p:outputLabel for="firstContactorPhoneNumber" value="第一联系人电话" />
							<p:inputText id="firstContactorPhoneNumber"
								value="#{serviceSupplierHome.instance.firstContactorPhoneNumber}"
								required="true" styleClass="input-small" />

							<p:outputLabel for="secondContactor" value="第二联系人" />
							<p:inputText id="secondContactor"
								value="#{serviceSupplierHome.instance.secondContactor}"
								styleClass="input-mini" />

							<p:outputLabel for="secondContactorPhoneNumber" value="第二联系人电话" />
							<p:inputText id="secondContactorPhoneNumber"
								value="#{serviceSupplierHome.instance.secondContactorPhoneNumber}"
								styleClass="input-small" />

							<p:outputLabel for="employeeCount" value="员工数" />
							<p:inputText id="employeeCount"
								value="#{serviceSupplierHome.instance.employeeCount}"
								styleClass="input-mini" />

							<p:outputLabel for="highTitleEmployeeCount" value="高级职称人数" />
							<p:inputText id="highTitleEmployeeCount"
								value="#{serviceSupplierHome.instance.highTitleEmployeeCount}"
								styleClass="input-mini" />

							<p:outputLabel for="mediumTitleEmployeeCount" value="中级职称人数" />
							<p:inputText id="mediumTitleEmployeeCount"
								value="#{serviceSupplierHome.instance.mediumTitleEmployeeCount}"
								styleClass="input-mini" />

							<p:outputLabel for="beginnerTitleEmployeeCount" value="初级职称人数" />
							<p:inputText id="beginnerTitleEmployeeCount"
								value="#{serviceSupplierHome.instance.beginnerTitleEmployeeCount}"
								styleClass="input-mini" />

							<p:outputLabel for="govServiceSupplier" value="是否政府服务供应商" />
							<p:selectBooleanCheckbox id="govServiceSupplier"
								value="#{serviceSupplierHome.instance.govServiceSupplier}" />

							<p:outputLabel for="region" value="中介机构所在地区" />
							<p:selectOneMenu id="region"
											 value="#{serviceSupplierHome.instance.region}"
											 required="true">
								<f:selectItem itemLabel="请选择" itemValue="#{null}"  />
								<f:selectItems value="#{codeDicUtils.getCodeDicList('所在地区')}" var="_codeDic" itemValue="#{_codeDic.codeValue}"
											   itemLabel="#{_codeDic.codeName}" />
							</p:selectOneMenu>

							<p:outputLabel for="alwaysValid" value="营业期限" />
							<p:selectOneButton id="alwaysValid"
								value="#{serviceSupplierHome.instance.alwaysValid}"
								required="true">
								<f:selectItem itemLabel="填写营业期限" itemValue="false" />
								<f:selectItem itemLabel="长期有效" itemValue="true" />
							</p:selectOneButton>
							
							<p:outputLabel for="busnissAllotedTime" value="输入期限" />
							<p:calendar id="busnissAllotedTime"
								value="#{serviceSupplierHome.instance.busnissAllotedTime}"
								pattern="yyyy-MM-dd" inputStyleClass="input-small"
								showOn="button" navigator="true" readonlyInput="true" />

							<p:outputLabel for="intro" value="机构简介" />
							<p:inputTextarea id="intro"
								value="#{serviceSupplierHome.instance.intro}" rows="5"
								style="width:80%" />
						</h:panelGrid>
					</p:panel>
					
			<p:remoteCommand name="updateBussinessPanel" immediate="true" update="businesses"></p:remoteCommand>
					<p:panel
						id="businesses"
						header="主营业务"
						widgetVar="businesses"
						style="margin-bottom:10px;"
						styleClass="nureg-cont nuregcbox nuregcboxsty"
					>
						<c:forEach
							items="#{serviceSupplierHome.instance.mainBusinesses}"
							var="_business"
							varStatus="_status"
						>
							<div class="certs">
								<p:commandLink
									styleClass="removeButton"
									rendered="#{_status.index > 0}"
									immediate="true"
									action="#{serviceSupplierHome.removeBusiness()}"
									ajax="true"
									oncomplete="updateBussinessPanel()">
									<f:setPropertyActionListener
										value="#{_business}"
										target="#{serviceSupplierHome.currentBusiness}"
									></f:setPropertyActionListener>
									<f:setPropertyActionListener
										value="#{_business.bussinessIndex}"
										target="#{serviceSupplierHome.currentBusinessIndex}"
									></f:setPropertyActionListener>
								</p:commandLink>
								<h2>主营业务#{_status.index + 1}</h2>
		
								<h:panelGrid
									columns="2"
									cellpadding="5"
								>
									<p:outputLabel
										for="agentServiceDetail#{_business.bussinessIndex}"
										value="服务事项"
									/>
									<p:outputPanel>
										<p:inputText
											id="agentServiceDetail#{_business.bussinessIndex}"
											widgetVar="agentServiceDetail#{_business.bussinessIndex}"
											value="#{_business.agentService.name}"
											required="true"
											readonly="true"
											styleClass="input-middle"
										/>
											<p:commandButton
												oncomplete="PF('chooseAgentServiceDialog').show();"
												value="选择"
												immediate="true"
												update="chooseAgentServiceDialog"
											>
												<f:setPropertyActionListener
													value="#{_business}"
													target="#{serviceSupplierHome.currentBusiness}"
												></f:setPropertyActionListener>
												<f:setPropertyActionListener
													value="#{_business.bussinessIndex}"
													target="#{serviceSupplierHome.currentBusinessIndex}"
												></f:setPropertyActionListener>
											</p:commandButton>
										
									</p:outputPanel>
		
									<p:outputLabel
										for="commitOfTime#{_business.bussinessIndex}"
										value="服务时限承诺"
									/>
									<p:inputText
										id="commitOfTime#{_business.bussinessIndex}"
										value="#{_business.commitOfTime}"
										required="true"
										styleClass="input-middle"
									/>
		
									<p:outputLabel
										for="commitOfPrice#{_business.bussinessIndex}"
										value="服务收费承诺"
									/>
									<p:inputText
										id="commitOfPrice#{_business.bussinessIndex}"
										value="#{_business.commitOfPrice}"
										required="true"
										styleClass="input-middle"
									/>
		
									<p:outputLabel
										for="commitOfQuality#{_business.bussinessIndex}"
										value="服务质量承诺"
									/>
									<p:inputText
										id="commitOfQuality#{_business.bussinessIndex}"
										value="#{_business.commitOfQuality}"
										required="true"
										styleClass="input-middle"
									/>
								</h:panelGrid>
							</div>
						</c:forEach>
	
						<p:commandButton
							action="#{serviceSupplierHome.instance.addEmptyBusiness()}"
							oncomplete="updateBussinessPanel()"
							value="添加业务"
							immediate="true"
						></p:commandButton>
					</p:panel>

					<p:panel id="attachmentsPanel" header="相关附件"
						style="margin-bottom:10px;"
						styleClass="nureg-cont nuregcbox nuregcboxsty">
						<p:fileUpload id="attachmentUploadFile" label="选择" mode="advanced"
							required="true" multiple="true" skinSimple="true"
							sizeLimit="#{1024 * 1024 * 3}" uploadLabel="上传" cancelLabel="取消"
							update="editForm:uploadedAttachments"
							fileUploadListener="#{serviceSupplierHome.uploadAttachment}" />
						<p:panel id="uploadedAttachments">
							<ul>
								<p:repeat var="_attachment"
									value="#{serviceSupplierHome.instance.attachments}">
									<li><h:outputText value="#{_attachment.filename}" /> <span>
											<p:commandLink
												action="#{serviceSupplierHome.removeAttachment(_attachment)}"
												update="editForm:uploadedAttachments" immediate="true">×</p:commandLink>
									</span></li>
								</p:repeat>
							</ul>
						</p:panel>
					</p:panel>

					<p:commandButton id='toolTipGrow1' action="#{serviceSupplierHome.reSubmit()}"
						value="重新提交" ajax="false" />
						<p:tooltip  for="toolTipGrow1" value="在审核期间，会影响您的选取！"
      									showEffect="clip" hideEffect="explode" position="bottom"/>
					<p:commandButton action="#{serviceSupplierHome.cancel()}"
						value="取消" immediate="true"></p:commandButton>
				</h:form>

			</div>
		</div>
		
		<p:dialog
			id="chooseAgentServiceDialog"
			widgetVar="chooseAgentServiceDialog"
			width="666"
			height="600"
			modal="true"
		>
			<h:form>
				<p:panel>
					<f:facet name="header">选择服务事项</f:facet>
					
					<p:scrollPanel style="height: 450px; border: 0px;" mode="native" >
						 <p:dataTable var="_service"  value="#{agentServiceList.resultList}" rows="10"
                         paginator="true"
                         paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                         rowsPerPageTemplate="5,10,15"
                          selection="#{serviceSupplierHome.selectedAgentServiceMap[serviceSupplierHome.currentBusinessIndex]}" rowKey="#{_service.name}">                   
                          <p:column selectionMode="single" style="width:16px;text-align:center"/>
					        <p:column headerText="服务事项名称">
					            <h:outputText value="#{_service.name}" />
					        </p:column>
				        	<p:column headerText="对应资质大类">
					            <h:outputText value="#{_service.qualificationClass.name}" />
					        </p:column>
				        </p:dataTable>
					</p:scrollPanel>

					<f:facet name="footer">
						<p:commandButton
							value="确定"
							action="#{serviceSupplierHome.updateAgentService()}"
							update="editForm:agentServiceDetail#{serviceSupplierHome.currentBusinessIndex}"
							oncomplete="PF('chooseAgentServiceDialog').hide();"
						/>
						<p:commandButton
							value="取消"
							onclick="PF('chooseAgentServiceDialog').hide();"
						/>
					</f:facet>
				</p:panel>
			</h:form>
		</p:dialog>
		
	</ui:define>
</ui:composition>
